﻿/****************************************************************
*   作者：Morain
*   创建时间：2018/2/24 19:10:53
*   描述说明：
*****************************************************************/
using Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hotfix
{
  class InnerMessageDispatcher : IMessageDispatcher
  {
    public void Dispatch(Session session, PacketInfo packetInfo)
    {
      Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Opcode);
      IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
      Game.Scene.GetComponent<MessageDispatcherComponent>().Handle(session, packetInfo.RpcId, message);
    }
  }
}